package com.lxc.demos.view;

import com.lxc.demos.R;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class TestViewActivity extends Activity {
	TabView tabView;
	Button entry,next;
	EditText total;
	
	int totalNum,currentIndex=1;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.testview);
		findViews();
		addEvents();
	}
	
	private void addEvents() {
		OnClickListener ocl = new OnViewClickListener();
		entry.setOnClickListener(ocl);
		next.setOnClickListener(ocl);
	}

	private void findViews(){
		tabView = (TabView) findViewById(R.id.tabView);
		entry = (Button) findViewById(R.id.entry);
		next = (Button) findViewById(R.id.next);
		total = (EditText) findViewById(R.id.total);
	}
	
	class OnViewClickListener implements OnClickListener{

		@Override
		public void onClick(View v) {
			if(v.equals(entry)){
				totalNum = Integer.parseInt(total.getText().toString());
				tabView.setValue(currentIndex, totalNum);
			}else if(v.equals(next)){
				currentIndex++;
				tabView.setValue(currentIndex, totalNum);
			}
		}
		
	}
	
	
	

}
